<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
use think\Request;
class Login extends Controller
{
    public function Login(Request $request){
      // $link = Db::connect('mysql://root:root@127.0.0.1:3306/thinkphp#utf8'
      //  = Db::connect();
      // 使用sql语句
      $postData = $request::instance()->post();
      $data = Db::execute('select * from user where name = :name and pwd = :pwd and role = :role',['name'=>$postData['name'],'pwd'=>$postData['pwd'],'role'=>$postData['role']]);
      if($data > 0){
        $this->success('登录成功','admin/index/index');
      }else{
        $this->success('登录失败','index/index/index');
      }
      
      
    }
}